import { Resolver, Query, Args } from '@nestjs/graphql';
import { BlockService } from './block.service';

@Resolver('Block')
export class BlockResolver {

  constructor(private readonly blockService: BlockService) {}

  @Query('block')
  async getBlock(@Args('id') id: number) {
    return this.blockService.findOneById(id);
  }

  @Query('blocks')
  async getBlocks(@Args() args: { page: number, pageSize: number }) {
    const { page = 1, pageSize = 20 } = args;
    const result = this.blockService.findWithPagination(page, pageSize);
    return result;
  }
}
